/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package co.uniminuto.park.dao;

import co.uniminuto.park.variables.VariablesGlobales;
import com.mongodb.DB;
import com.mongodb.Mongo;
import java.net.UnknownHostException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Esteban Rozo
 */
public class ConexionMongo {

    private Mongo Conexion;

    public Mongo getConexion() {
        return Conexion;
    }

    public void setConexion(Mongo Conexion) {
        this.Conexion = Conexion;
    }

    public Mongo conectar() {


        try {
            this.Conexion = new Mongo(VariablesGlobales.DireccionBD, VariablesGlobales.puertoBD);
            //this.Conexion.
           
            DB db=this.Conexion.getDB("parking");
            db.authenticate("esteban", "jennifer24".toCharArray());
            System.err.println("Conexion Exitosa");
        } catch (UnknownHostException ex) {
            Logger.getLogger(ConexionMongo.class.getName()).log(Level.SEVERE, null, ex);
            System.out.println("eerooooo: " +ex);
            this.Conexion = null;
        }

        return this.Conexion;
    }

    public static void main(String args[]) {
        ConexionMongo co = new ConexionMongo();
        co.conectar();

    }
}
